package com.nuoyuan.wx.service.helper;

import com.nuoyuan.wx.common.utils.DateUtil;
import com.nuoyuan.wx.vo.UserVo;
import com.nuoyuan.wx.common.utils.StringUtils;
import com.nuoyuan.wx.dao.po.UserPo;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * @Package com.nuoyuan.wx.service.helper
 * @ClassName UserBeanHepler
 * @Description TODO
 * @Author linus
 * @Date 2020-02-21 15:11
 * @Version 1.0
 **/
public class UserBeanHepler {
    public static List<UserVo> toVos(List<UserPo> pos) {
        if(CollectionUtils.isEmpty(pos)) {
            return new ArrayList();
        }

        List<UserVo> vos = new ArrayList<>();
        for(UserPo po : pos) {
            vos.add(toVo(po));
        }
        return vos;
    }

    public static UserVo toVo(UserPo po) {
        UserVo vo = new UserVo();
        vo.setIdNo(po.getIdNo());
        vo.setPhone(po.getPhone());
        vo.setRealName(po.getRealName());
        vo.setUserId(po.getUserId());
        vo.setCreateTime(DateUtil.formatDate(po.getCreateTime(), DateUtil.FMT_DATE_YYYYMMDD_HHMMSS));
        vo.setRiskLevel(po.getRiskLevel());
        return vo;
    }

    public static UserPo toPo(UserVo vo) {
        UserPo po = new UserPo();
        po.setIdNo(po.getIdNo());
        po.setPhone(po.getPhone());
        po.setRealName(po.getRealName());
        po.setUserId(po.getUserId());
        return po;
    }

}
